//Adam Pozorek s6593
#include <cstdio>
struct ulamek {
	unsigned int l;
	unsigned int m;	
};
void sort (struct ulamek *a, int n)
{
struct ulamek x;
int i, j, max;

	for(i = 0; i < n-1; i++)
	{
		max = i;
		for(j = i + 1; j < n; j++)
		{
			int w;
			if((((a+j)->l)*((a+max)->m))>(((a+max)->l)*((a+j)->m))){
				w = 1; 
			}else{
				w = 0;
			}

			if(w) max = j;
			if(max != i) {
				x = a[max]; 
				a[max] = a[i]; 
				a[i] = x;
			}
		}
	}
}
int NWD(int a, int b)
{
	int c=0;
	if(a==b){ 
		return a;
	}else{
		if(a>b){c=b;b=a;a=c;c=0;}
		c=b-a;b=c;
		NWD(a,b);
	}
}
ulamek sm(struct ulamek *u,int size)
{
	struct ulamek ul;
	int i = 0;
	ul.m = u[i].m*u[i+1].m;
	ul.l = ((u[i].l)*u[i+1].m)+((u[i+1].l)*(u[i].m));
	for(i = 2; i < size; i++)
	{
		ul.l=((u[i].l)*(ul.m))+((ul.l)*(u[i].m));
		ul.m=u[i].m*ul.m;
	}
	
	int nwd = NWD(ul.l,ul.m);
	ul.l=ul.l/nwd;
	ul.m=ul.m/nwd;
	return ul; 		
}
int policz(int * tab, int tLen){
	int liczba = 0;
	int inkr = 1;
	for(int i = tLen-1; i >= 0;i--){
		int x = static_cast<int>(tab[i]);
		x = x - 48;
		liczba = (x*inkr) + liczba;
		inkr = inkr*10;
	}
	return liczba;

}

int main() {
	
	int k, ile, index;
	index  = 0;
	int liczMian = 0;
	char c;
	int max =4,m;
	int uTmp[10];
	struct ulamek * ul;
	scanf("%i", &k);
	struct ulamek *u_wynik = new ulamek[k];

		for(int i = 0; i < k; i++)
		{	
			
			ile = getchar();
			struct ulamek *u = new ulamek[ile];
			unsigned char j = 0, wariant = 0;
			int liczba = 0, max;

		do{
			max = 0;
			c = getchar();
			while(((char)c)!=' '){
				uTmp[j++]=c;
				c = getchar();
			}

 			max = policz(uTmp,j);
			struct ulamek *u = new ulamek[max];
			int s = j = liczba = 0;
			c = getchar();
			while(c!=10) {

				while(((char)c)!='/' && ((char)c)!=' ' && c!=10){
					uTmp[j++]=c;
					c = getchar();		
				}
				if(c=='/' || c==' ' || c==10){

					liczba = policz(uTmp,j);
					j=0;
					if(wariant==0){
						ul->l = liczba;
						wariant = 1;
					}else{
						ul->m = liczba;
						wariant = 0;
						u[s++]=*ul;
					}

				}
				if(c!=10) c = getchar();

			}

		}while(c!=10);


				if(ile>1){
					struct ulamek ula;
					ula = sm(u,ile);
					u_wynik[index].l=ula.l;
					u_wynik[index].m=ula.m; 
					index++;
				} else if(ile==1) {
					u_wynik[index].m=(u[0]).m;
					u_wynik[index].l=(u[0]).l;
					index++;
				}
			delete [] u;
		}
 
	sort(u_wynik, index);
	for(int y=0; y<index; ++y)
	{
		printf("%i%c%i \n", u_wynik[y].l, c,u_wynik[y].m);
	}
}
